package com.example.resubmit.domain;

import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
@Component
public class ResubmitInterceptorConfig {
    // 自定一扫描路径，以实际项目为主
    public static final String EXECUTION = "execution(* com.xx.xx.xx.*.web..*(..))";

    @Autowired
    ResubmitInterceptor interceptor;

    @Bean
    public DefaultPointcutAdvisor defaultPointcutAdvisor2() {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression(EXECUTION);

        // 配置增强类advisor
        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
        advisor.setPointcut(pointcut);
        advisor.setAdvice(interceptor);
        return advisor;
    }
}
